package 算法.练习1;

import 算法.NiuKe.ListNode;

import java.util.Arrays;

/**
 * @author:谢君臣
 * @Date:2021/8/16-11:46
 * @version:1.0
 * @function:
 */
public class NC3 {
    public static void main(String[] args) {
        Arrays.sort(new int[]{1});
    }
    public ListNode EntryNodeOfLoop(ListNode pHead) {
        if (pHead==null||pHead.next==null)
            return null;
        ListNode slow =pHead;
        ListNode fast =pHead;
        while (fast!=null&&fast.next!=null){
            slow = slow.next;
            fast= fast.next.next;
            if (slow == fast) {
                slow = pHead;
                break;
            }
        }
        while (fast!=null&& fast!=slow){
            fast = fast.next;
            slow = slow.next;
        }
        return fast;
    }
}
